/**
 * "Visual Paradigm: DO NOT MODIFY THIS FILE!"
 * 
 * This is an automatic generated file. It will be regenerated every time 
 * you generate persistence class.
 * 
 * Modifying its content may cause the program not work, or your work may lost.
 */

/**
 * Licensee: nu uc
 * License Type: Evaluation
 */
package org.testis.orm.classes;

import org.orm.*;

public class T_bed_dut {
    public T_bed_dut() {
    }

    public boolean save() throws PersistentException {
	try {
	    org.testis.orm.manager.TestisDbPersistentManager.instance()
		    .saveObject(this);
	    return true;
	} catch (Exception e) {
	    e.printStackTrace();
	    throw new PersistentException(e);
	}
    }

    public boolean delete() throws PersistentException {
	try {
	    org.testis.orm.manager.TestisDbPersistentManager.instance()
		    .deleteObject(this);
	    return true;
	} catch (Exception e) {
	    e.printStackTrace();
	    throw new PersistentException(e);
	}
    }

    public boolean refresh() throws PersistentException {
	try {
	    org.testis.orm.manager.TestisDbPersistentManager.instance()
		    .getSession().refresh(this);
	    return true;
	} catch (Exception e) {
	    e.printStackTrace();
	    throw new PersistentException(e);
	}
    }

    public boolean evict() throws PersistentException {
	try {
	    org.testis.orm.manager.TestisDbPersistentManager.instance()
		    .getSession().evict(this);
	    return true;
	} catch (Exception e) {
	    e.printStackTrace();
	    throw new PersistentException(e);
	}
    }

    public boolean deleteAndDissociate() throws PersistentException {
	try {
	    if (getSerial() != null) {
		getSerial().t_bed_dut.remove(this);
	    }

	    if (getPc() != null) {
		getPc().t_bed_dut.remove(this);
	    }

	    if (getDslam() != null) {
		getDslam().t_bed_dut.remove(this);
	    }

	    if (getDeviceDefinition() != null) {
		getDeviceDefinition().t_bed_dut.remove(this);
	    }

	    if (getActiveFirmware() != null) {
		getActiveFirmware().t_bed_dut.remove(this);
	    }

	    return delete();
	} catch (Exception e) {
	    e.printStackTrace();
	    throw new PersistentException(e);
	}
    }

    public boolean deleteAndDissociate(org.orm.PersistentSession session)
	    throws PersistentException {
	try {
	    if (getSerial() != null) {
		getSerial().t_bed_dut.remove(this);
	    }

	    if (getPc() != null) {
		getPc().t_bed_dut.remove(this);
	    }

	    if (getDslam() != null) {
		getDslam().t_bed_dut.remove(this);
	    }

	    if (getDeviceDefinition() != null) {
		getDeviceDefinition().t_bed_dut.remove(this);
	    }

	    if (getActiveFirmware() != null) {
		getActiveFirmware().t_bed_dut.remove(this);
	    }

	    try {
		session.delete(this);
		return true;
	    } catch (Exception e) {
		return false;
	    }
	} catch (Exception e) {
	    e.printStackTrace();
	    throw new PersistentException(e);
	}
    }

    private void this_setOwner(Object owner, int key) {
	if (key == org.testis.orm.manager.ORMConstants.KEY_T_BED_DUT_SERIAL) {
	    this.Serial = (org.testis.orm.classes.T_bed_serialconnection) owner;
	}

	else if (key == org.testis.orm.manager.ORMConstants.KEY_T_BED_DUT_PC) {
	    this.Pc = (org.testis.orm.classes.T_bed_testpc) owner;
	}

	else if (key == org.testis.orm.manager.ORMConstants.KEY_T_BED_DUT_DSLAM) {
	    this.Dslam = (org.testis.orm.classes.T_bed_dslam) owner;
	}

	else if (key == org.testis.orm.manager.ORMConstants.KEY_T_BED_DUT_DEVICEDEFINITION) {
	    this.DeviceDefinition = (org.testis.orm.classes.T_bed_devicedefinitions) owner;
	}

	else if (key == org.testis.orm.manager.ORMConstants.KEY_T_BED_DUT_ACTIVEFIRMWARE) {
	    this.ActiveFirmware = (org.testis.orm.classes.T_bed_firmware) owner;
	}
    }

    org.orm.util.ORMAdapter _ormAdapter = new org.orm.util.AbstractORMAdapter() {
	public void setOwner(Object owner, int key) {
	    this_setOwner(owner, key);
	}

    };

    private int id;

    private org.testis.orm.classes.T_bed_serialconnection Serial;

    private String testBedIp;

    private org.testis.orm.classes.T_bed_testpc Pc;

    private org.testis.orm.classes.T_bed_dslam Dslam;

    private org.testis.orm.classes.T_bed_devicedefinitions DeviceDefinition;

    private org.testis.orm.classes.T_bed_firmware ActiveFirmware;

    private String name;

    private Boolean isSerialActive;

    private void setId(int value) {
	this.id = value;
    }

    public int getId() {
	return id;
    }

    public int getORMID() {
	return getId();
    }

    public void setTestBedIp(String value) {
	this.testBedIp = value;
    }

    public String getTestBedIp() {
	return testBedIp;
    }

    public void setName(String value) {
	this.name = value;
    }

    public String getName() {
	return name;
    }

    public void setIsSerialActive(boolean value) {
	setIsSerialActive(new Boolean(value));
    }

    public void setIsSerialActive(Boolean value) {
	this.isSerialActive = value;
    }

    public Boolean getIsSerialActive() {
	return isSerialActive;
    }

    public void setSerial(
	    org.testis.orm.classes.T_bed_serialconnection value) {
	if (Serial != null) {
	    Serial.t_bed_dut.remove(this);
	}
	if (value != null) {
	    value.t_bed_dut.add(this);
	}
    }

    public org.testis.orm.classes.T_bed_serialconnection getSerial() {
	return Serial;
    }

    /**
     * This method is for internal use only.
     */
    private void setORM_Serial(
	    org.testis.orm.classes.T_bed_serialconnection value) {
	this.Serial = value;
    }

    private org.testis.orm.classes.T_bed_serialconnection getORM_Serial() {
	return Serial;
    }

    public void setPc(org.testis.orm.classes.T_bed_testpc value) {
	if (Pc != null) {
	    Pc.t_bed_dut.remove(this);
	}
	if (value != null) {
	    value.t_bed_dut.add(this);
	}
    }

    public org.testis.orm.classes.T_bed_testpc getPc() {
	return Pc;
    }

    /**
     * This method is for internal use only.
     */
    private void setORM_Pc(org.testis.orm.classes.T_bed_testpc value) {
	this.Pc = value;
    }

    private org.testis.orm.classes.T_bed_testpc getORM_Pc() {
	return Pc;
    }

    public void setDslam(org.testis.orm.classes.T_bed_dslam value) {
	if (Dslam != null) {
	    Dslam.t_bed_dut.remove(this);
	}
	if (value != null) {
	    value.t_bed_dut.add(this);
	}
    }

    public org.testis.orm.classes.T_bed_dslam getDslam() {
	return Dslam;
    }

    /**
     * This method is for internal use only.
     */
    private void setORM_Dslam(org.testis.orm.classes.T_bed_dslam value) {
	this.Dslam = value;
    }

    private org.testis.orm.classes.T_bed_dslam getORM_Dslam() {
	return Dslam;
    }

    public void setDeviceDefinition(
	    org.testis.orm.classes.T_bed_devicedefinitions value) {
	if (DeviceDefinition != null) {
	    DeviceDefinition.t_bed_dut.remove(this);
	}
	if (value != null) {
	    value.t_bed_dut.add(this);
	}
    }

    public org.testis.orm.classes.T_bed_devicedefinitions getDeviceDefinition() {
	return DeviceDefinition;
    }

    /**
     * This method is for internal use only.
     */
    private void setORM_DeviceDefinition(
	    org.testis.orm.classes.T_bed_devicedefinitions value) {
	this.DeviceDefinition = value;
    }

    private org.testis.orm.classes.T_bed_devicedefinitions getORM_DeviceDefinition() {
	return DeviceDefinition;
    }

    public void setActiveFirmware(
	    org.testis.orm.classes.T_bed_firmware value) {
	if (ActiveFirmware != null) {
	    ActiveFirmware.t_bed_dut.remove(this);
	}
	if (value != null) {
	    value.t_bed_dut.add(this);
	}
    }

    public org.testis.orm.classes.T_bed_firmware getActiveFirmware() {
	return ActiveFirmware;
    }

    /**
     * This method is for internal use only.
     */
    private void setORM_ActiveFirmware(
	    org.testis.orm.classes.T_bed_firmware value) {
	this.ActiveFirmware = value;
    }

    private org.testis.orm.classes.T_bed_firmware getORM_ActiveFirmware() {
	return ActiveFirmware;
    }

    public String toString() {
	return toString(false);
    }

    public String toString(boolean idOnly) {
	if (idOnly) {
	    return String.valueOf(getId());
	} else {
	    StringBuffer sb = new StringBuffer();
	    sb.append("T_bed_dut[ ");
	    sb.append("Id=").append(getId()).append(" ");
	    if (getSerial() != null)
		sb.append("Serial.Persist_ID=")
			.append(getSerial().toString(true)).append(" ");
	    else
		sb.append("Serial=null ");
	    sb.append("TestBedIp=").append(getTestBedIp()).append(" ");
	    if (getPc() != null)
		sb.append("Pc.Persist_ID=").append(getPc().toString(true))
			.append(" ");
	    else
		sb.append("Pc=null ");
	    if (getDslam() != null)
		sb.append("Dslam.Persist_ID=")
			.append(getDslam().toString(true)).append(" ");
	    else
		sb.append("Dslam=null ");
	    if (getDeviceDefinition() != null)
		sb.append("DeviceDefinition.Persist_ID=")
			.append(getDeviceDefinition().toString(true))
			.append(" ");
	    else
		sb.append("DeviceDefinition=null ");
	    if (getActiveFirmware() != null)
		sb.append("ActiveFirmware.Persist_ID=")
			.append(getActiveFirmware().toString(true)).append(" ");
	    else
		sb.append("ActiveFirmware=null ");
	    sb.append("Name=").append(getName()).append(" ");
	    sb.append("IsSerialActive=").append(getIsSerialActive())
		    .append(" ");
	    sb.append("]");
	    return sb.toString();
	}
    }

}
